# 成员方法的两种调用方式
# 方法1: 对象名.方法名()
# 方法2: 类名.方法名(具体对象)

class Master(object):
    def __init__(self):
        self.kongfu = '[传统方法]'
        pass

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')
        pass


# 2 定义HeimaSchool类 /kongfu /make_cake
class HeimaSchool(object):
    def __init__(self):
        self.kongfu = '[黑马配方]'
        pass

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')
        pass


# 2 定义徒弟类 继承Master HeimaSchool
class Prentice(Master, HeimaSchool):
    def __init__(self):
        self.kongfu = '[独创摊煎饼技术]'
        pass

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')
        pass

    # 通过父类名.方法名(self)来调用父类的方法
    def make_master_cake(self):
        Master.__init__(self)
        Master.make_cake(self)
        pass


    def make_school_cake(self):
        # super().__init__()            # 1 从多个类继承, 默认按照第1个类 Master
        # super().make_cake()

        # HeimaSchool.__init__(self)      # 2 若想使用黑马  方式一
        # HeimaSchool.make_cake(self)
        # print(self.kongfu)

        # super(HeimaSchool, self).__init__()       # 3 不同
        # super(HeimaSchool, self).make_cake()
        # 3 出错的原因是: Prentice的父类是 Master
        # [<class '__main__.Prentice'>,
        # <class '__main__.Master'>,
        # <class '__main__.HeimaSchool'>,
        # <class 'object'>]

        super(Master, self).__init__()              # 4 还是按照第1个参数  Master的Super即HeimaSchool
        super(Master, self).make_cake()
        pass



# 调用类对象的两种方法
def dm01_调用类对象两种方法():

    # 方法1: 对象名.方法名()
    mymaster01 = Master()
    mymaster01.make_cake()

    # 方法2: 类名.方法名(具体对象)
    Master.make_cake(mymaster01)


def dm02_多继承中使用super():
    myprentice01 =  Prentice()
    myprentice01.make_school_cake()
    print(Prentice.mro())
    pass


if __name__ == '__main__':
    dm01_调用类对象两种方法()

    print("-"*30)
    dm02_多继承中使用super()
    print('调用类方法 End')



